/*	This program produces Figure C.6 */

***** Set directories 
local dir_clean 	"~/Dropbox/Retirement gaming/clean"
local dir_output 	"~/Dropbox/Retirement gaming/output/dataverse"

use "`dir_clean'/mainsample_medbcw.dta", clear

* Sets of controls		
local listcontrols = " i.t i.ciiu2_1stobs i.ndep_cat_1stobs i.ndep_cat i.year#i.i.ciiu2_1stobs i.year#i.ndep_cat_1stobs "  

label var pre25 "2-5 Pre BCW"
label var post03 "0-3 Post BCW"
label var post4 "4+ Post BCW"


** Regression All Employees Small Firms **
estimates clear
preserve
keep if  empl==1 &  large_1stobs==0 
sum W if time_bcw==-1
local meanw=r(mean)
g Wz=W/`meanw'		
eststo A: reghdfe Wz pre6 pre25 post03 post4, absorb(`listcontrols') vce(cluster i ) 
restore
** Regression Employees Small Firms High Employment Attachment **
preserve
keep if  empl==1 &  large_1stobs==0 & prop_mempl>=0.7  & tenure1yrs_at49==1
sum W if time_bcw==-1
local meanw=r(mean)
g Wz=W/`meanw'		
eststo B: reghdfe Wz pre6 pre25 post03 post4, absorb(`listcontrols') vce(cluster i ) 
restore
** Regression Employees Micro High Attachment Stayers **
preserve
keep if  empl==1 &  large_1stobs==0 & prop_mempl>=0.7 & tenure1yrs_at49==1 & match_firm49==1 
sum W if time_bcw==-1
local meanw=r(mean)
g Wz=W/`meanw'		
eststo C: reghdfe Wz pre6 pre25 post03 post4, absorb(`listcontrols') vce(cluster i ) 
restore
** PLOT **
coefplot (A, label(Full Sample) msymbol(O)) ///
	(B, label(Frequently Employed) msymbol(D)) ///
	(C, label(Freq. Employed, Same Firm) msymbol(S)) ///
	, bylabel(Small-Firm Employee) ///
	||, keep(*:pre25 post03 post4) xline(0)   ///
	ciopts(recast(rcap)) levels(90 95) scheme(s2color) graphregion(color(white)) legend(pos(2) ring(0) col(1))  norecycle
graph export "`dir_output'/figureC6.png",  replace 	

		
clear all
exit

 
